package com.example.demo.behavior.mediator;

import java.util.HashSet;
import java.util.Set;

/**
 * @Desc:
 * @Author zzz
 * @Date 2021/2/24
 * @Version V1.0
 */
public class LianJia implements Medium {

    Set<Customer> customerSet = new HashSet<>();

    @Override
    public void register(Customer customer) {
        customerSet.add(customer);
    }

    @Override
    public void relay(Customer customer, String msg) {
        for (Customer tempCustomer : customerSet) {
            if (!tempCustomer.equals(customer)) {
                tempCustomer.receive(customer.getName(), msg);
            }
        }
    }
}
